﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Coffee_Restaurant.Database;

namespace Coffee_Restaurant.DAL
{
    class PrinterDa
    {
        public static int Update(string printerName, int id)
        {
            try
            {
                using (var db = new DatabaseEntities())
                {
                    var model = db.Printers.FirstOrDefault(x => x.PrinterId == id); // may in thanh toan
                    if (model != null) model.PrinterName = printerName;
                    return db.SaveChanges();
                }
            }
            catch (Exception)
            {
                return 0;
            }
        }

        public static string GetDefaultPrinter(int id)
        {
            using (var db = new DatabaseEntities())
            {
                var model = db.Printers.FirstOrDefault(x => x.PrinterId == id);
                if (model != null)
                {
                    return model.PrinterName;
                }
                return null;
            }
        }
    }
}
